import java.math.BigDecimal;
import java.math.RoundingMode;


/**
 * Copyright (C) 2013  Arun Lee & Bryce Nagareda
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @author briceorbryce
 *
 */
public class SundialVertMath extends SundialMath {

	/**Serial version UID*/
	private static final long serialVersionUID = 1L;
	
	/**
	 * smath object passed from sundialmath. <br />
	 * Super class takes care of any errors.
	 * 
	 * @param smath horizontal math object
	 */
	public SundialVertMath(SundialMath smath) {
		this.latitude = smath.getLatitude();
		this.longitude = smath.getLongitude();
		this.day = smath.getDay();
		this.month = smath.getMonth();
		this.tz = smath.getTimeZone();
		this.HourLines = smath.getHourLines();
		calculateHourLines();
	}
	
	/**
	 * Calculates the hour lines.
	 */
	/* (non-Javadoc)
	 * @see SundialMath#calculateHourLines()
	 */
	@Override
	protected void calculateHourLines(){
		BigDecimal temp;
		double sunrise = 6;
		
		//apply equation of time correction
		sunrise = sunrise - EOTCorrection();
		
		for(int i = 0; i < this.HourLines.length; i++){
			this.HourLines[i] = Math.toDegrees(Math.atan(Math.cos(Math.toRadians(Math.abs(this.latitude)))*(Math.tan(Math.toRadians((sunrise-12)*15)))));
			temp = BigDecimal.valueOf(this.HourLines[i]);
			temp = temp.setScale(3, RoundingMode.HALF_UP);
			this.HourLines[i] = temp.doubleValue(); 
			sunrise = sunrise + 0.5;
		}
	}
}
